<script src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
<script>
isWeiXin();
function isWeiXin(){
	
var ua = navigator.userAgent.toLowerCase();
var isWeixin = ua.indexOf('micromessenger') != -1;
var isAndroid = ua.indexOf('android') != -1;
var isIos = (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1);
if(!isWeixin||!isMobile()) {
	location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid=000000&redirect_uri=http%3A%2F%2Faaa.aaa.cn&response_type=code&scope=snsapi_userinfo&state=0&connect_redirect=1#wechat_redirect";
}
}

//判断是否为手机
function isMobile() {
	var sUserAgent = navigator.userAgent.toLowerCase(),
		bIsIpad = sUserAgent.match(/ipad/i) == "ipad",
		bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os",
		bIsMidp = sUserAgent.match(/midp/i) == "midp",
		bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4",
		bIsUc = sUserAgent.match(/ucweb/i) == "ucweb",
		bIsAndroid = sUserAgent.match(/android/i) == "android",
		bIsCE = sUserAgent.match(/windows ce/i) == "windows ce",
		bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile",
		bIsWebview = sUserAgent.match(/webview/i) == "webview";
	
	return(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM);
}
wx.config({
    debug: false,
    appId: "{$wxparam.appId}",
    timestamp: "{$wxparam.timestamp}",
    nonceStr: "{$wxparam.nonceStr}",
    signature: "{$wxparam.signature}",
    jsApiList: [
      'checkJsApi',
      'openAddress',
      'onMenuShareTimeline',
      'onMenuShareAppMessage',
      'onMenuShareQQ',
      'onMenuShareWeibo',
      'onMenuShareQZone',
      'hideMenuItems',
      'showMenuItems',
      'hideAllNonBaseMenuItem',
      'showAllNonBaseMenuItem',
      'translateVoice',
      'startRecord',
      'stopRecord',
      'onVoiceRecordEnd',
      'playVoice',
      'onVoicePlayEnd',
      'pauseVoice',
      'stopVoice',
      'uploadVoice',
      'downloadVoice',
      'chooseImage',
      'previewImage',
      'uploadImage',
      'downloadImage',
      'getNetworkType',
      'openLocation',
      'getLocation',
      'hideOptionMenu',
      'showOptionMenu',
      'closeWindow',
      'scanQRCode',
      'chooseWXPay',
      'openProductSpecificView',
      'addCard',
      'chooseCard',
      'openCard'
    ]
});
wx.ready(function () {
hidewxdefaultmenu();
wx.showMenuItems({ 
	menuList: [ 'menuItem:profile', 
                'menuItem:addContact'
                ] 
                ,success: function (res) {
                	//alert(JSON.stringify(res))
      	      },
    	      fail: function (res) {
    	    	 // alert(JSON.stringify(res))
    	      }
});
});

wx.error(function (res) {
});


$(function(){
	$(".lookBigPic").click(function(){
		var obj = this;
		lookBigPic(obj.src);
	});
});


function lookBigPic(curr,list){
	if(list==null){
		list=new Array();
		list.push(curr);
	}
	wx.previewImage({

	    current: curr,

	    urls: list

	});
}


function hidewxdefaultmenu(){
	
	wx.hideMenuItems({
	      menuList: [
	      'menuItem:originPage',
	      'menuItem:openWithSafari',
	      'menuItem:share:email',
	      'menuItem:exposeArticle',
	        'menuItem:readMode', 
	        'menuItem:openWithQQBrowser',
	        'menuItem:copyUrl'
	      ],
	      success: function (res) {
	      },
	      fail: function (res) {
	      }
	    });
	
}
function wxpays(val,c1) {
	$.post("{:url('api/ajaxchongzhi')}", {
		shopId: val
	}, function(res) {

		if(res.flag != 0) {
			alert("系统繁忙");
		} else {
			var money = res.data.money;
			$('.score_recharge').hide();
			$('.bodys').hide();
			callpay(res.data.data, function() {
				if(c1!=null){
					c1(parseInt(money));
				}
			});

		}

	}, 'json').error(function() {
		alert("系统繁忙");
	});
}
</script>